﻿using SuperX.SuperSocket.Client.UpLoad;
using System.Net;

namespace SuperX.SuperSocket.Client
{
    internal class TransferEngine : ITransferEngine
    {
        private FileUploadingEvents _FileUploadingEvents;

        public IFileUploadingEvents FileUploadingEvents
        { get { return _FileUploadingEvents; } }

        public TransferEngine()
        {
            _FileUploadingEvents = new FileUploadingEvents();
        }

        public void BeginUpLoad(string fileName, string saveName, string ip, int port)
        {
            EndPoint endpoint = new IPEndPoint(IPAddress.Parse(ip), port);
            UpLoadEngine engine = new UpLoadEngine(_FileUploadingEvents);
            engine.Init(endpoint, fileName, saveName);
            engine.BeginUpLoad();
        }

        public void BeginSendMessger(string msg, string ip, int port)
        {
            EndPoint endpoint = new IPEndPoint(IPAddress.Parse(ip), port);
            UpLoadEngine engine = new UpLoadEngine(_FileUploadingEvents);
            engine.Init(endpoint, "", "");
            engine.SendStr(msg);
        }
    }
}